package com.zhulin.android.edoctor;

import com.zhulin.android.edoctor.view.ClickListenerForScrolling;
import com.zhulin.android.edoctor.view.MyHorizontalScrollView;
import com.zhulin.android.edoctor.view.SizeCallbackForMenu;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class BaseActivity extends FragmentActivity{

	View mViewProfile;
	View mViewBaseContent;
	Button btnMore;
	private TextView txtPageTitle;

	//public LinearLayout linearLayoutContainer;
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		
		
		getSystemInfo();
		initViews();
	}
	
	public void setPageTitle(String title){
		txtPageTitle.setText(title);
	}

	EDApplication edApplication;
	private void getSystemInfo(){
		edApplication=(EDApplication)getApplication();
		if(edApplication.getScreendpi()==0)
		{	
			DisplayMetrics dm = new DisplayMetrics();  
			getWindowManager().getDefaultDisplay().getMetrics(dm);  
			edApplication.setScreendpi(dm.widthPixels);
			edApplication.setScreenHeightdpi(dm.heightPixels);
		}
	}

	private void initViews(){

		LayoutInflater inflater = LayoutInflater.from(this);
		setContentView(inflater.inflate(R.layout.layout_frame_scrollview, null));

		MyHorizontalScrollView scrollView = (MyHorizontalScrollView) findViewById(R.id.myScrollView);
		mViewProfile = findViewById(R.id.linearLayoutProfile);
		mViewProfile.setVisibility(View.INVISIBLE);

		mViewBaseContent=inflater.inflate(R.layout.activity_basecontent, null);
		
		mViewBaseContent.findViewById(R.id.btnShowCase).setOnClickListener(clickListenerShowCaseList);
		mViewBaseContent.findViewById(R.id.btnShowMyCase).setOnClickListener(clickListenerShowSelftCaseList);
		mViewBaseContent.findViewById(R.id.btnCamerUpload).setOnClickListener(clickListenerUploadCase);
		btnMore=(Button)mViewBaseContent.findViewById(R.id.btnMore);
		//linearLayoutContainer=(LinearLayout)mViewBaseContent.findViewById(R.id.linearLayoutBaseContentContainer);
		btnMore.setOnClickListener(new ClickListenerForScrolling(scrollView, mViewProfile));
		txtPageTitle=(TextView)mViewBaseContent.findViewById(R.id.txtPageTitle);

		View transparent = new TextView(this);
		transparent.setBackgroundColor(android.R.color.transparent);

		final View[] children = new View[] { transparent, mViewBaseContent };

		int scrollToViewIdx = 1;
		scrollView.initViews(children, scrollToViewIdx, new SizeCallbackForMenu(btnMore));
	}
	
	private OnClickListener clickListenerShowCaseList=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			showCaseList();
		}
	};
	
	private OnClickListener clickListenerShowSelftCaseList=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			showSelftCaseList();
		}
	};
	
	private OnClickListener clickListenerUploadCase=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			uploadCase();
		}
	};
	
	protected void showCaseList(){
		
	}
	
	protected void showSelftCaseList(){
		
	}
	
	protected void uploadCase(){
		
	}
}
